package de.baumann.browser.activitys.center

import android.content.Context
import android.content.Intent
import de.baumann.browser.R
import de.baumann.browser.api.net.vo.OdinWithdrawRecord
import de.baumann.browser.base.BaseOdinActivity
import de.baumann.browser.base.BasePresenter
import de.baumann.browser.iview.IBaseView
import de.baumann.browser.utils.TimeUtil
import kotlinx.android.synthetic.main.activity_withdraw_progress.*
import kotlinx.android.synthetic.main.include_tool_bar.*
import java.util.*

/**
 *@author:
 *@date:2019/7/12 19:48
 *@discription: 提现进度
 */
@Deprecated("废弃")
class WithdrawProgressActivity : BaseOdinActivity<IBaseView, BasePresenter<IBaseView>>() {
    override fun createPresenter(): BasePresenter<IBaseView>? {
        return null
    }

    override fun createView(): IBaseView? {
        return null
    }

    companion object {
        fun startWithdrawProgressActivity(context: Context, withdrawRecord: OdinWithdrawRecord) {
            val intent = Intent(context, WithdrawProgressActivity::class.java).apply {
                putExtra("withdrawRecord", withdrawRecord)
            }
            context.startActivity(intent)
        }
    }

    override fun getLayout(): Int {
        return R.layout.activity_withdraw_progress
    }

    override fun initView() {
        initToolbar(commToolBar, commTitle)
    }

    override fun getTitleText(): String {
        return getString(R.string.withdrawal_progress)
    }

    override fun initData() {
        val withdrawRecord = intent.getSerializableExtra("withdrawRecord") as OdinWithdrawRecord
        setProgressCount(withdrawRecord.profit)
        setProgressPoundage(withdrawRecord.poundage)
        setProgressAccount(withdrawRecord.ethAddress)
        val date = TimeUtil.getDateByFormat(withdrawRecord.createDate, "yyyy-MM-dd HH:mm:ss")
        val expectedDate = TimeUtil.getDateByOffset(date, Calendar.DATE, 1)
        setExpectedTime(TimeUtil.getStringByFormat(expectedDate, "yyyy-MM-dd HH:mm:ss"))
    }

    private fun setProgressCount(count: String) {
        tvProgressCount.text = count
    }

    private fun setProgressPoundage(poundage: String) {
        tvProgressPoundage.text = poundage
    }

    private fun setProgressAccount(transferAmount: String) {
        tvProgressAccount.text = transferAmount
    }

    private fun setExpectedTime(expectedTime: String) {
        tvExpectedTime.text = String.format(getString(R.string.expected_arrive, expectedTime))
    }
}
